package com.eshin.configuration.beanprocessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.support.SimpleThreadScope;

/**
 * @author Eshin
 * @title: CustomBeanFactoryPostProcessor
 * @projectName pay
 * @date 2019/6/1717:27
 */

/**
 * BeanFactoryPostProcessor主要用于修改bean定义，对beanFactory中的相关参数进行修改
 */
public class CustomBeanFactoryPostProcessor implements  BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        System.out.println(beanFactory.getBeanDefinitionNames().length);
//        beanFactory.getBeanDefinition("helloController").setInitMethodName("initController");
        beanFactory.registerScope("thread",new SimpleThreadScope());
        System.out.println("CustomBeanFactoryPostProcessor postProcessBeanFactory");
    }

}
